using System;
using SKBKontur.Serialization.Helpers;

namespace SKBKontur.Serialization.Binding
{
    public class Utf8StringBinder : ScalarBinder
    {
        public Utf8StringBinder(string columnName) : base(columnName)
        {
        }

        public Utf8StringBinder()
        {
        }

        public override byte[] SerializeValue(object value)
        {
            return ((string) value).ToUtf8ByteArray();
        }

        public override object UnserializeValue(Type type, byte[] data)
        {
            return data.ToUtf8Str();
        }
    }
}